package com.wl.android.flutterdemo

import android.content.Intent
import android.os.Bundle
import android.os.PersistableBundle
import android.util.Log
import com.idlefish.flutterboost.FlutterBoost
import com.idlefish.flutterboost.FlutterBoostRouteOptions
import com.idlefish.flutterboost.containers.FlutterBoostActivity
import io.flutter.embedding.android.FlutterActivityLaunchConfigs


// Created by wangliang on 2024/7/11.
class WLFlutterBoostActivity : FlutterBoostActivity() {

    companion object {

        fun launchFlutterPage(options: FlutterBoostRouteOptions) {
            val intent = CachedEngineIntentBuilder(WLFlutterBoostActivity::class.java)
                .backgroundMode(FlutterActivityLaunchConfigs.BackgroundMode.opaque)
                .destroyEngineWithActivity(false)
                .uniqueId(options.uniqueId())
                .url(options.pageName())
                .urlParams(options.arguments() ?: hashMapOf())
                .build(FlutterBoost.instance().currentActivity())
            FlutterBoost.instance().currentActivity().startActivityForResult(intent, options.requestCode())
        }
    }

    override fun onUpdateSystemUiOverlays() {
        val resources = StatusBarUtils.app?.resources ?: return
        val statusBarColor = resources.getColor(android.R.color.transparent)
        StatusBarUtils.initStatusBar(this, true, statusBarColor, StatusBarMode.MODE_LIGHT)
    }
}